package com.weecee.zs.utils.al;

import org.apache.commons.lang3.ArrayUtils;

import java.util.HashMap;
import java.util.List;

public class Solution {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i = 0;i<nums.length;i++) {
            int elemt = nums[i];
            if(map.containsKey(target-elemt)) {
                int[] rets = {map.get(target-elemt),i};
                return rets;
            }else{
                map.put(elemt,i);
            }
        }
        int [] empty={};
        return empty;
    }

    public List<List<Integer>> threeSum(int[] nums) {
        HashMap<Integer, Integer> map = new HashMap<>();
        //第一边，将位值放入到HASH中
        //第二边，遍历HASH每个值，并判断
        return null;
    }


    public static void main(String[] args) {
        int[] inputs = {1,2,3,4,5,6,7,8,9};
        Solution solution = new Solution();
        int[] ints = solution.twoSum(inputs, 5);
        System.out.println(ArrayUtils.toString(ints));
    }
}